(function (angular) {
  'use strict';

  angular.module('services.customActivity.realtime')
    .service('dialogFormService', dialogFormService);

  function dialogFormService($mdDialog, $q) {
    var that = this;

    that.newDialog = function (ev, formState) {
      var dialogOptions = {
        targetEvent: ev,
        parent: angular.element(document.body),
        templateUrl: 'views/customActivity/addActivity.html',
        locals: {
          formState: formState
        },
        controller: 'realtimeFormController'
      };
      dialogOptions.targetEvent = ev;

      return $mdDialog.show(dialogOptions);
    };

    that.confirm = function (content) {
      var deferred = $q.defer();
      if(window.confirm(content)){
        deferred.resolve();
      } else {
        deferred.reject();
      }
      return deferred.promise;
    };

    that.alert = function (content) {
      window.alert(content);
    }
  }
})(angular);